home *** CD-ROM | disk | FTP | other *** search
- { pen.pas -- Select pen styles }
-
- program PenStyles;
-
- uses WinTypes, WinProcs, WObjects;
-
- type
-
- PenApplication = object(TApplication)
- procedure InitMainWindow; virtual;
- end;
-
- PPenWindow = ^PenWindow;
- PenWindow = object(TWindow)
- constructor Init(AParent: PWindowsObject; ATitle: PChar);
- procedure Paint(PaintDC: HDC; var PaintInfo: TPaintStruct);
- virtual;
- end;
-
- { PenApplication }
-
- {- Initialize the application's window }
- procedure PenApplication.InitMainWindow;
- begin
- MainWindow := New(PPenWindow, Init(nil, 'Pen Styles'))
- end;
-
- { PenWindow }
-
- {- Initialize the application's window object }
- constructor PenWindow.Init(AParent: PWindowsObject; ATitle: PChar);
- begin
- TWindow.Init(AParent, ATitle);
- with Attr do
- begin
- X := 20; Y := 20; W := 411; H := 250
- end
- end;
-
- {- Paint graphics in window }
- procedure PenWindow.Paint(PaintDC: HDC; var PaintInfo:
- TPaintStruct);
- var
- X, Delta, Width: Integer;
- R: TRect;
-
- procedure DrawLine(Style, Width: Integer);
- var
- OldPen, ThePen: HPen;
- begin
- ThePen := CreatePen(Style, Width, RGB(0, 0, 0));
- OldPen := SelectObject(PaintDC, ThePen);
- MoveTo(PaintDC, X, 4);
- LineTo(PaintDC, X, R.Bottom - 4);
- X := X + Delta;
- SelectObject(PaintDC, OldPen);
- DeleteObject(ThePen)
- end;
-
- begin
- GetClientRect(HWindow, R);
- X := 10;
- Delta := R.Right div 20;
- for Width := 1 to 4 do
- begin
- DrawLine(ps_Solid, Width);
- DrawLine(ps_Dash, Width);
- DrawLine(ps_Dot, Width);
- DrawLine(ps_DashDot, Width);
- DrawLine(ps_DashDotDot, Width)
- end
- end;
-
- var
-
- PenApp: PenApplication;
-
- begin
- PenApp.Init('PenApp');
- PenApp.Run;
- PenApp.Done
- end.
-
-
- {--------------------------------------------------------------
- Copyright (c) 1991 by Tom Swan. All rights reserved.
- Revision 1.00 Date: 2/20/1991
- ---------------------------------------------------------------}
-
-